<template>
	<el-dialog
		:visible="true"
		width="70%"
		:destroy-on-close="true"
		class="rempadding"
		:before-close="handleClose"
	>
		<div slot="title" class="dialog-title">
			<span class="title-text" style="margin-right: 15px">
				{{ rowVal.discountName }}
			</span>
		</div>
		<el-table
			v-loading="loading"
			border
			size="mini"
			show-summary
			:data="tableData"
			class="small-size-table"
			style="margin-bottom: 15px"
			:header-cell-style="getRowClass"
			element-loading-spinner="el-icon-loading"
			:summary-method="(val) => handleDialogRow(val, subSummary)"
		>
			<el-table-column
				prop="staticsDate"
				align="center"
				:label="$t('report.date')"
			></el-table-column>
			<el-table-column
				prop="discountAmountIn"
				align="center"
				:label="$t('report.discount_amount')"
			>
				<template slot-scope="scope">
					<p>
						{{
							handleTotalNumber(
								'CNY',
								scope.row.discountAmountInCNY
							)
						}}
					</p>
					<p>
						{{
							handleTotalNumber(
								'THB',
								scope.row.discountAmountInTHB
							)
						}}
					</p>
					<p>
						{{
							handleTotalNumber(
								'VND',
								scope.row.discountAmountInVND
							)
						}}
					</p>
				</template>
			</el-table-column>
			<el-table-column
				prop="discountCount"
				align="center"
				:label="$t('report.discount_count')"
			>
				<template slot-scope="scope">
					{{ handleNumber('', scope.row.discountCount, 0)
					}}{{ $t('report.ci') }}
				</template>
			</el-table-column>
		</el-table>
		<!-- <div slot="footer" class="dialog-footer" style="text-align: center">
			<el-button @click="handleClose">关闭</el-button>
		</div> -->
	</el-dialog>
</template>
<script>
import list from '@/mixins/list'
import summaryList from './summaryList'
export default {
	mixins: [list, summaryList],
	props: {
		rowVal: {
			type: Object,
			default: () => {}
		},
		closeDialog: {
			type: Function,
			default: () => {}
		}
	},
	data() {
		return {
			loading: false,
			tableData: [],
			subSummary: {}
		}
	},
	methods: {
		loadData() {
			this.loading = true
			this.pageCurrency = this.rowVal?.currency || ''
			this.$api
				.getReportDiscountReportDetail(this.rowVal)
				.then((res) => {
					this.loading = false
					this.tableData = res?.data?.record || []
					this.subSummary = res?.data?.summary || {}
				})
				.catch(() => {
					this.loading = false
				})
		},
		handleClose() {
			this.closeDialog(false)
		}
	}
}
</script>
<style lang="scss" scoped>
::v-deep .footer_count_row {
	padding: 0;
}
::v-deep .el-table__body-wrapper {
	overflow-y: auto;
	max-height: 45vh;
}
</style>
